﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using XZTZ.UMP.Public.Models.Flow;
using XZTZ.UMP.WEB.Data;

namespace XZTZ.UMP.WEB.Pages.Flow.FlowTemplateStep
{
    public class CreateModel : PageModel
    {
        private readonly XZTZ.UMP.WEB.Data.ApplicationDbContext _context;

        public CreateModel(XZTZ.UMP.WEB.Data.ApplicationDbContext context)
        {
            _context = context;
        }
        public SelectList Genres { get; set; }
        [BindProperty(SupportsGet = true)]
        public string MovieGenre { get; set; }
        public IActionResult OnGet()
        {
            ViewData["strStepTypeID"] = new SelectList(_context.Set<Base_SignatureStepType>(), "strStepTypeID", "strStepTypeName");
            ViewData["guidRuleID"] = new SelectList(_context.Set<Flow_StepRule>(), "guidRuleID", "strTitle");
            string StepID = HttpContext.Session.GetString("fid");
            Guid lextId = new Guid();
            DataTable  Base_SignatureStepType = FlowBusiness.AppSetting.GetStepListByFlowID(new Guid(StepID), lextId);

         
           
            return Page();
        }

        [BindProperty]
        public Flow_TemplateStep Flow_TemplateStep { get; set; }

        public async Task<IActionResult> OnPostAsync()
        {  //查询所有用户 



            if (!ModelState.IsValid)
            {
                return Page();
            }
            if (HttpContext.Session.GetString("fid") != null)
            {
                Flow_TemplateStep.guidFlowID = new Guid(HttpContext.Session.GetString("fid"));
            }

            _context.Flow_TemplateStep.Add(Flow_TemplateStep);
            await _context.SaveChangesAsync();

            return RedirectToPage("./Index");
        }
    }
}